import { Module } from "vuex";

const types = {
  UPDATE_USER: "update_user",
};
// state
const state = {
  clickNum: 0,
};

// getters
const getters = {
  getClickNum: (state) => {
    return state.clickNum;
  },
};

// mutations
const mutations = {
  [types.UPDATE_USER ](state, num) {
    state.clickNum += num;
  },
};

// actions
const actions = {
  updateClickNum({ commit }, num) {
    commit(types.UPDATE_USER, num);
    // await等待操作完成再往下走
  },
};

const demo = {
  namespaced: true,
  state,
  getters,
  actions,
  mutations,
};

export default demo;
